home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / asm / utils / cryptdevice / resetdev.c < prev   
C/C++ Source or Header  |  1980-01-03  |  1KB  |  72 lines

  1. /*
  2.  * resetdev.c
  3.  *
  4.  */
  5.  
  6. #include <exec/types.h>
  7. #include <exec/devices.h>
  8. #include <exec/io.h>
  9.  
  10. #ifdef __SASC
  11. #include <proto/exec.h>
  12. int CXBRK(void) {return 0;}
  13. #endif
  14.  
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17.  
  18. struct MsgPort *MPort = NULL;
  19. struct IOStdReq *Req = NULL;
  20. struct Device *Dev = NULL;
  21.  
  22. char *dev_name = "crypt.device";
  23.  
  24. main(int argc, char *argv[])
  25. {
  26.   int unit;
  27.   int err = 10;
  28.  
  29.   if(argc != 2 && argc != 3)
  30.      {
  31.     fprintf(stderr, "Usage: %s unitnumber [devicename]\n", argv[0]);
  32.     exit(10);
  33.      }
  34.  
  35.   if(argc == 3) dev_name = argv[2];
  36.  
  37.   unit = atoi(argv[1]);
  38.  
  39.   if((MPort = CreatePort(0,0)) == NULL)
  40.      {
  41.     fprintf(stderr, "Can't create message port\n");
  42.     goto cleanexit;
  43.      }
  44.  
  45.   if((Req = (struct IOStdReq *)CreateExtIO(MPort,
  46.     sizeof(struct IOStdReq))) == NULL)
  47.      {
  48.     fprintf(stderr, "Can't create IORequest\n");
  49.     goto cleanexit;
  50.      }
  51.  
  52.   if(OpenDevice(dev_name, unit, Req, 0))
  53.      {
  54.     fprintf(stderr, "Can't open %s\n", dev_name);
  55.     goto cleanexit;
  56.      }
  57.  
  58.   Dev = Req->io_Device;
  59.  
  60.  
  61.   Req->io_Command = CMD_RESET;
  62.   DoIO(Req);
  63.  
  64.   err = 0;
  65.  
  66. cleanexit:
  67.   if(Dev) CloseDevice(Req);
  68.   if(Req) DeleteExtIO(Req);
  69.   if(MPort) DeletePort(MPort);
  70.   exit(err);
  71. }
  72.